package cheqex.dao;

import org.apache.torque.util.Criteria;
import java.util.Date;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/*
Deposit Cash Peer:
addDepositCash - adds deposit cash data
editDepositCash - edit deposit cash data 
deleteDepositCash -  delete deposit cash data
*/
public class DepositCashPeer extends cheqex.dao.BaseDepositCashPeer
{
	public static boolean addDepositCash(String orNumber, int amt, String particulars, java.sql.Date orDate, int id){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		criteria.add(DepositCashPeer.AMOUNT, amt);
		criteria.add(DepositCashPeer.PARTICULARS, particulars);
		criteria.add(DepositCashPeer.ORDATE, orDate);
		criteria.add(DepositCashPeer.WEEKID, id);
		
		try{
			DepositCashPeer.doInsert(criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static List<DepositCash> retrieveAllDepositCash(java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORDATE, date);
		
		try{
			return (List<DepositCash>)DepositCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCash>();
		}
	}
	
	public static boolean editDepositCash(String orNumber, int amt, String particulars, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.AMOUNT, amt);
		criteria.add(DepositCashPeer.PARTICULARS, particulars);
		
		Criteria scriteria = new Criteria();
		scriteria.add(DepositCashPeer.ORNUMBER, orNumber);
		scriteria.add(DepositCashPeer.ORDATE, date);
		
		try{
			DepositCashPeer.doUpdate(scriteria, criteria);
			return true;
		}catch (Exception e) { 
			e.printStackTrace(); 
			return false;
		}
	}
	
	public static boolean deleteDepositCash(String orNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		criteria.add(DepositCashPeer.ORDATE, date);
		try{
			DepositCashPeer.doDelete(criteria);
			return true;
		}catch (Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public static DepositCash getOR(String orNumber, java.sql.Date date){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		criteria.add(DepositCashPeer.ORDATE, date);
		
		try{
			if((DepositCash)DepositCashPeer.doSelect(criteria).get(0)!=null)
				return (DepositCash)DepositCashPeer.doSelect(criteria).get(0);
			else return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public static List<DepositCash> getData(String orNumber){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		
		try{
			return (List<DepositCash>)DepositCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static List<DepositCash> filterDepositCashByORNo(String orNumber){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		
		try{
			return (List<DepositCash>)DepositCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCash>();
		}
	}
	
	public static List<DepositCash> filterDepositCashByORDate(java.sql.Date orDate){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORDATE, orDate);
		try{
			return (List<DepositCash>)DepositCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCash>();
		}
	}
	
	public static List<DepositCash> searchDepositCashParticular(String orNumber, java.sql.Date orDate){
		Criteria criteria = new Criteria();
		criteria.add(DepositCashPeer.ORNUMBER, orNumber);
		criteria.add(DepositCashPeer.ORDATE, orDate);
		
		try{
			return (List<DepositCash>)DepositCashPeer.doSelect(criteria);
		}catch(Exception e){
			e.printStackTrace();
			return new ArrayList<DepositCash>();
		}
	}
}
